<link rel="stylesheet" type="text/css" href="assets/bootstrap-datepicker/css/datepicker.css" />
<section id="main-content">
  <section class="wrapper">
    <div class="row">
      <div class="col-lg-12">
        <div class="alert alert-block alert-warning fade in">
          <button data-dismiss="alert" class="close close-sm" type="button">
            <i class="icon-remove"></i>
          </button>
          <strong>注意事项：</strong><br/>
          1、填写进展时，开始时间要以上周周六开始，结束时间填写周五；<br/>
          2、如果提示实际投入百分比填写问题，请检查是否别的子任务中的投入百分比填写过多，别的子任务填写三天内可删除后修改；<br/>
          3、填写进度时候即使出现实际周期不是一个礼拜，请填写时候把也要按照一个礼拜为单位（上周周六到周五）来填写，并且把实际百分比分摊到一个礼拜的单位。比如完成日期是周二，实际投入是80%，则按照一个礼拜单位折算为4*80%/7=46% 并且完成日期选周五。
        </div>
       
            <div class="alert alert-block alert-danger fade in">
              <button data-dismiss="alert" class="close close-sm" type="button">
                <i class="icon-remove"></i>
              </button>
              <strong>友情提示：</strong>
              如果输入内容时候想排版实现换行，可在需要换行的地方增加&lt;/br&gt;，即可实现排版换行。
            </div>
         
        <section class="panel">
          <header class="panel-heading">
            OKR子任务进展信息
          </header>
          <form>
            <div class="panel-body">
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">完成周期*</label>
                <div class="col-sm-10">
                  <input id="datetime" style="width: 25%;display:initial;" name="startTime" type="text" value=""
                         class="form-control" disabled placeholder="开始时间">
                  至
                  <input id="datetime-1" style="width: 25%;display:initial;" name="endTime" type="text" value=""
                         class="form-control" placeholder="结束时间" autocomplete="off">
                </div>
              </div>

              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">KR完成率</label>
                <div class="col-sm-10">
                  <input name="krWcl" type="text" onkeyup="clearNoNum(this)"  onblur="clearNoNum(this)" certus-required value="" class="form-control">
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">实际投入百分比</label>
                <div class="col-sm-10">
                  <input name="inPercent" id="inPercent" type="text" onkeyup="clearNoNum(this)"  onblur="clearNoNum(this)" certus-required value="" class="form-control">
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">目标进展和困难</label>
                <div class="col-sm-10">
                  <textarea class="form-control" maxlength="120" id="jzv" name="rwDesc" certus-required></textarea>
                </div>
              </div>
              <div class="form-group customerForm">
                <label class="col-sm-2 control-label">下一步计划</label>
                <div class="col-sm-10">
                  <textarea class="form-control" maxlength="120" id="nextPlan" certus-required name="nextPlan"></textarea>
                </div>
              </div>
              <p class="default-buttons">
                <a href="javascript:back();" class="button-back btn btn-info">返回</a>
                <a href="javascript:addPlan();" class="button-next  btn btn-info">提交</a>
              </p>
            </div>
          </form>
        </section>
        <section class="panel">
          <header class="panel-heading">
            更新历史
          </header>
          <div class="panel-body">
            <div id="childLogContainer" class="dlshouwen-grid-container"></div>
            <div id="childLogToolBarContainer" class="dlshouwen-grid-toolbar-container"></div>
          </div>
        </section>
      </div>
    </div>
  </section>
</section>
<script type="text/javascript" src="assets/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script src="js/okr/index.js"></script>
<script>
  $('#datetime').datepicker({
    format: 'yyyy-mm-dd'
  });
  $('#datetime-1').datepicker({
      format: 'yyyy-mm-dd'
  }).on('changeDate', function (e) {
      var date = new Date($("#datetime-1").val().replace(/-/, "/").replace("-", "/"));
      //计算相差多少天
      var d = new Date();
      var time = d.getTime() - date.getTime();
      var days = parseInt(time / (1000 * 60 * 60 * 24));
      if (days > 15) {
          layer.msg("结束日期不能超过当前日期15天");
          $("#datetime-1").val("");
          $("#datetime").val("");
          return;
      }

      var weekDay = [7, 1, 2, 3, 4, 5, 6];
      if (weekDay[date.getDay()] != 5) {
          layer.msg("结束日期必须为星期五");
          $("#datetime-1").val("");
          $("#datetime").val("");
          return;
      } else {
          //开始日期为结束日期的前6天
          var now = new Date(date.getTime() - 86400000 * 6);
          var year = now.getFullYear(),
              month = (now.getMonth() + 1).toString(),
              day = now.getDate().toString();
          if (month.length == 1) {
              month = '0' + month;
          }
          if (day.length == 1) {
              day = '0' + day;
          }
          var datetime = (year + '-' + month + '-' + day);
          $("#datetime").val(datetime);
          //计算剩余投入占比
          $CertusFormAjax.ajax('findByDateTime',{"time":$("#datetime-1").val()},function (result) {
              var syInput = 100;
              syInput = syInput - result.data;
              $$scope.syInput = syInput;
              $("#inPercent").attr("placeholder","剩余投入百分比："+syInput);
          });
      }
  });
</script>